﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Handrise.CDCable.Mobile.Business;

namespace Handrise.CDCable.Mobile.UI
{
    public partial class FrmGISlayer :FrmBase
    {
        private string parentForm = "";
        private object parentInfo;
        private string wheresql;
        private EquipmentTypeService equipmentTypeService = new EquipmentTypeService();

        public FrmGISlayer()
        {
            InitializeComponent();
            ttlbrhead.Text = ResourceImage.GIS;
            //获取所有设备类型
            ibpageprev.UpImage = ResourceImage.上一页可点击;
            ibpageprev.DownImage = ResourceImage.上一页点击;
            ibpageprev.DisableImage = ResourceImage.上一页灰;
            ibpagenext.UpImage = ResourceImage.下一页可点击;
            ibpagenext.DownImage = ResourceImage.下一页点击;
            ibpagenext.DisableImage = ResourceImage.下一页灰;
            ilstdown.Images.Add(ResourceImage.确定02);
            ilstdown.Images.Add(ResourceImage.空白);
            ilstdown.Images.Add(ResourceImage.返回02);
            ilstbcup.Images.Add(ResourceImage.确定01);
            ilstbcup.Images.Add(ResourceImage.空白);
            ilstbcup.Images.Add(ResourceImage.返回01);
     
        }


        private void bcxunjian_OnButtonClick(object sender, int buttonIndex)
        {

        }

        private void bcxunjian_OnButtonClick_1(object sender, int buttonIndex)
        {
            switch (buttonIndex)
            {
                case 0:
                    {
                        foreach (string devicename in dlEquipmentType.SelectItemKey )
                        {
                            wheresql = wheresql + " or DeviceType='" + devicename+"'"; 
                        }
                        if (wheresql != "")
                            wheresql = wheresql.Substring(4, wheresql.Length - 4);
                        FormManage.GotoNext(parentForm, new object[] { parentForm, wheresql }, null, true);
                        break;
                    }
                case 1:
                        break;

                case 2:

                        FormManage.GotoNext(parentForm, new object[] { parentForm, "" }, null, true);
      
                        break;
      
            }

            }

        private void FrmGISlayer_Load(object sender, EventArgs e)
        {
            LoadData();
            List<EquipmentType> equipmentTypes = equipmentTypeService.GetAllEquipmentType();
            dlEquipmentType.DataSource = equipmentTypes;
            dlEquipmentType.DisplayMember = "FTYPENAME";
            dlEquipmentType.KeyMember = "FTYPENAME"; 
            dlEquipmentType.DataBind();
            dlEquipmentType.IsRadio = false;
            SetButtonState();
        }

        private void dlEquipmentType_OnItemClick(HandRise.MBHOP.Controls.DataListItem item)
        {
        
        }

        private void ibpagenext_Click(object sender, EventArgs e)
        {
        
        }

        private void ibpageprev_Click(object sender, EventArgs e)
        {
        
        }
        /// <summary>
        /// 加载数据
        /// </summary>
        private void LoadData()
        {
            parentForm = (string)Parameter[0];
            parentInfo = Parameter[1];
        }

        private void dlDevices_OnItemClick(HandRise.MBHOP.Controls.DataListItem item)
        {

        }
        private void SetButtonState()
        {
            ibpagenext.Enabled = dlEquipmentType.PageCount > 0 && dlEquipmentType.PageIndex < dlEquipmentType.PageCount;
            ibpageprev.Enabled = dlEquipmentType.PageCount > 0 && dlEquipmentType.PageIndex > 1;
            lblPageInfo.Text = dlEquipmentType.PageIndex.ToString() + "/" + dlEquipmentType.PageCount.ToString();
        }

        private void ibpageprev_Click_1(object sender, EventArgs e)
        {
            dlEquipmentType.PreviousPage();
            SetButtonState();
        }

        private void ibpagenext_Click_1(object sender, EventArgs e)
        {
            dlEquipmentType.NextPage();
            SetButtonState();
        }

        private void bcxunjian_Click(object sender, EventArgs e)
        {

        }

    }
}